package chpt_05_01_adaptor;

import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;

/**
 * @author Ping
 * @date 2023/3/30 9:00
 **/

/**
 * Adaptee role: demo for Adaptor pattern.
 *
 */
@Component("md5Encoder")
public class MD5Encoder {
    /**
     * md5 encoding method
     * @param text
     * @return
     * @throws Throwable
     */
    public String encode(String text) throws Throwable {
        return DigestUtils.md5DigestAsHex(
                text.getBytes("utf-8"));
    }

}
